<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = []
        arr.length = 100;
        arr.fill(1, 0, arr.length);
        let fn1 = arr => {
            console.time('for')
            for (let i = 0; i < arr.length; i++) {
                console.log(arr[i])
            }
            console.timeEnd('for')
        }
        fn1(arr)

        // for循环

        let fn2 = arr => {
            console.time('in')
            for (let key in arr) {
                console.log(1)
            }
            console.timeEnd('in')
        }
        fn2(arr)

        // for in 

        let fn3 = arr => {
            console.time('forEach')
            arr.forEach(v => console.log(v))
            console.timeEnd('forEach')
        }
        fn3(arr)

        //forEach 不能中断循环  

        let fn4 = arr => {
            console.time('of')
            for (let key of arr) {
                console.log(key)
            }
            console.timeEnd('of')
        }
        fn4(arr)

        //for of
    </script>
</body>

</html>